package com.itheima.ThreadAPI;

public class MyThread2 extends Thread{
    public MyThread2() {
    }

    public MyThread2(String name) {
        super(name);
    }

    @Override
    public void run() {
        for (int i = 0; i < 5; i++) {
            if (i==2){
                try {
                    Thread.sleep(4000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println(Thread.currentThread().getName()+":"+i);
        }
    }
}
class Test1 {
    public static void main(String[] args) {
        Thread myThread2 = new MyThread2("子线程2");
        Thread myThread3 = new MyThread2("子线程3");
        myThread2.start();
        myThread3.start();

        for (int i = 0; i < 5; i++) {
            System.out.println(Thread.currentThread().getName()+":"+i);
        }
    }
}